﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace NScheduler
{
    /// <summary>
    /// NScheduler quque
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class NSQueue<T> : IEnumerable<T>, ICollection, IEnumerable
    {
        public NSQueue()
        {
            _queue = new Queue<T>();
        }

        Queue<T> _queue;

        public void Enqueue(T t)
        {
            if (!Contains(t))
            {
                _queue.Enqueue(t);
            }
        }

        internal void Clear()
        {
            _queue.Clear();
        }

        public bool Contains(T t)
        {
            return _queue.Contains(t);
        }

        public bool Contains(T t, EqualityComparer<T> comp)
        {
            return _queue.Contains(t, comp);
        }

        public IEnumerator<T> GetEnumerator()
        {
            return _queue.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return _queue.GetEnumerator();
        }

        public int Count
        {
            get { return _queue.Count; }
        }

        public T this[int index]
        {
            get { return (T)_queue.ToArray()[index]; }
            set { _queue.ToArray()[index] = value; }
        }

        public void CopyTo(T[] array, int index)
        {
            _queue.CopyTo(array, index);
        }

        void ICollection.CopyTo(Array array, int index)
        {
            _queue.CopyTo((T[])array, index);
        }

        int ICollection.Count
        {
            get { return _queue.Count; }
        }

        bool ICollection.IsSynchronized
        {
            get { throw new NotImplementedException(); }
        }

        object ICollection.SyncRoot
        {
            get { throw new NotImplementedException(); }
        }
    }
}
